local niuwei = fk.CreateSkill {
  name = "wk_heg__niuwei",
}

Fk:loadTranslationTable{
  ["wk_heg__niuwei"] = "牛威",
  [":wk_heg__niuwei"] = "准备阶段，你可弃置所有手牌对一名角色造成1点伤害，然后本回合的结束阶段，若其已死亡，你摸等量的牌。",

  ["#wk_heg__niuwei-choose"] = "牛威：选择一名角色，对其造成1点伤害",

  ["$wk_heg__niuwei1"] = "势如熊罴，威震四海！",
  ["$wk_heg__niuwei2"] = "啸聚熊虎，免走狐惊！",
}

niuwei:addEffect(fk.EventPhaseStart, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(niuwei.name) and player == target and player.phase == Player.Start and player:getHandcardNum() > 0
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local to = room:askToChoosePlayers(player,{
      targets = room.alive_players,
      min_num = 1,
      max_num = 1,
      prompt = "#wk_heg__niuwei-choose",
      skill_name = niuwei.name,
      cancelable = true,
    })
    if #to > 0 then
      event:setCostData(self, {to = to[1]})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local to = event:getCostData(self).to
    local num = player:getHandcardNum()
    player:throwAllCards("h")
    player.room:damage{
      from = player,
      to = to,
      damage = 1,
      damageType = fk.NormalDamage,
      skillName = niuwei.name,
    }
    player.room:setPlayerMark(to, "@@wk_heg__niuwei-turn", 1)
    player.room:setPlayerMark(player, "_wk_heg__niuwei_card-turn", num)
  end,
})

niuwei:addEffect(fk.EventPhaseStart, {
  anim_type = "special",
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return player == target and player:usedSkillTimes(niuwei.name, Player.HistoryTurn) > 0 
      and player.phase == Player.Finish and player:getMark("_wk_heg__niuwei_card-turn") ~= 0
      and not table.find(player.room.alive_players, function (p) return p:getMark("@@wk_heg__niuwei-turn") ~= 0 end)
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player:drawCards(player:getMark("_wk_heg__niuwei_card-turn"), niuwei.name)
  end,
})

return niuwei